home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / SYSINT.ASM < prev    next >
Assembly Source File  |  1989-11-16  |  2KB  |  106 lines

  1.  
  2.     TITLE   i86_sysint
  3.  
  4. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  5. _TEXT    ENDS
  6. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  7. _DATA    ENDS
  8. CONST    SEGMENT  WORD PUBLIC 'CONST'
  9. CONST    ENDS
  10. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  11. _BSS    ENDS
  12. DGROUP    GROUP    CONST,    _BSS,    _DATA
  13.     ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  14. _TEXT      SEGMENT
  15.  
  16.  
  17.     PUBLIC _i86_sysint
  18.     ;i86_sysint(interrupt, inregs, outregs)
  19.     ;Does a software interrupt from C.
  20.     ;Returns flags in ax
  21.     ;interrupt is 16 bit saying which interrupt to generate.
  22.     ;inregs and outregs are the following structure:
  23.     ;struct i86_byte_regs 
  24.     ;    {
  25.     ;    unsigned char al, ah, bl, bh, cl, ch, dl, dh;
  26.     ;    unsigned int si, di, ds, es;
  27.     ;    };
  28.     ;Inregs and outregs may usually point to the same structure
  29.     ;This generates a warning during assembly but works ok.
  30. _i86_sysint PROC far
  31.     push bp
  32.     mov bp,sp
  33.     push bx
  34.     push si
  35.     push di
  36.     push es
  37.     push ds
  38.  
  39.     ;grab interrupt number and use it to modify intit code  (no ROM for me!)
  40.     mov ax,[bp+4+2]
  41.     mov byte ptr cs:intit+1,al
  42.  
  43.     ;point ds:di to input parameters
  44.     lds di,[bp+6+2]
  45.     mov ax,[di]
  46.     mov bx,[di+2]
  47.     mov cx,[di+4]
  48.     mov dx,[di+6]
  49.     mov si,[di+8]
  50.     push ax
  51.     mov ax,[di+14]
  52.     mov es,ax
  53.     mov ax,ss
  54.     mov cs:oss,ax
  55.     mov cs:osp,sp
  56.     pop ax
  57.     lds di,[di+10]
  58. intit:
  59.     int 0
  60.     cli
  61.     mov cs:oax,ax
  62.     mov ax,cs:oss
  63.     mov ss,ax
  64.     mov sp,cs:osp
  65.     sti
  66.     pop ax    ;
  67.     mov ax,cs:oax
  68.     ;save ds:di and point 'em to output parameters
  69.     push ds
  70.     push di
  71.     lds di,[bp+10+2]
  72.     mov [di],ax
  73.     mov [di+2],bx
  74.     mov [di+4],cx
  75.     mov [di+6],dx
  76.     mov [di+8],si
  77.     pop ax    ;'di' into ax
  78.     mov [di+10],ax
  79.     pop ax    ;'ds' into ax
  80.     mov [di+12],ax
  81.     mov ax,es
  82.     mov [di+14],ax
  83.  
  84.     ;move flags to ax (the return value...)
  85.     pushf    
  86.     pop ax
  87.  
  88.     pop ds
  89.     pop es
  90.     pop di
  91.     pop si
  92.     pop bx
  93.     pop bp
  94.     ret
  95. oax equ this word
  96.     dw 0
  97. oss equ this word
  98.     dw 0
  99. osp equ this word
  100.     dw 0
  101. _i86_sysint endp
  102.  
  103.  
  104. _TEXT    ENDS
  105. END
  106.